part of '../../repository.dart';

const _kRegularAppStoreTransactionOfferTypeValue = 'regular';
const _kIntruductoryAppStoreTransactionOfferTypeValue = 'introductory';
const _kPromotionalAppStoreTransactionOfferTypeValue = 'promotional';
const _kSubscriptionCodeAppStoreTransactionOfferTypeValue = 'subscription_code';

class _AppStoreTransactionOfferTypeDto extends Equatable {
  const _AppStoreTransactionOfferTypeDto._internal({
    required this.offerTypeString,
  });

  final String offerTypeString;

  @override
  List<Object?> get props {
    return [
      offerTypeString,
    ];
  }

  factory _AppStoreTransactionOfferTypeDto.fromString(String offerTypeString) {
    return _AppStoreTransactionOfferTypeDto._internal(
      offerTypeString: offerTypeString,
    );
  }

  AppStoreTransactionOfferType toEntity() {
    return switch (offerTypeString) {
      _kRegularAppStoreTransactionOfferTypeValue => AppStoreTransactionOfferType.regular,
      _kIntruductoryAppStoreTransactionOfferTypeValue => AppStoreTransactionOfferType.introductory,
      _kPromotionalAppStoreTransactionOfferTypeValue => AppStoreTransactionOfferType.promotional,
      _kSubscriptionCodeAppStoreTransactionOfferTypeValue =>
        AppStoreTransactionOfferType.subscriptionCode,
      _ => throw UnimplementedError(),
    };
  }
}
